<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRegionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('regions', function (Blueprint $table) {
            $table->increments('id');
            $table->string('code', 8)->unique();
            $table->string('pcode', 8);
            $table->string('name', 40);
            $table->string('short_name', 40);
            $table->tinyInteger('level');
            $table->string('tel_code', 8)->nullable();
            $table->string('zip_code', 10)->nullable();
            $table->string('pinyin', 125)->nullable();

            $table->timestamps();
            $table->softDeletes();
            $table->index('id');
            $table->index('pcode');
            $table->index('name');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('regions');
    }
}
